from selenium import webdriver
from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options
from time import sleep, ctime
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
 
user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7'
headers={'User-Agent':user_agent,} 

opts = Options()
#opts.set_headless()
opts.headless = True
assert opts.headless  # no graphical interface
 
driver = webdriver.Firefox(options=opts)
driver.get('https://duckduckgo.com')


try:
    element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "myDynamicElement"))
    )
finally:
    driver.quit()

	
search_form = driver.find_element_by_id('search_form_input_homepage')
search_form.send_keys('real python')
search_form.submit()
results = driver.find_elements_by_class_name('result')
print(results[0].text)
driver.close()
quit()